home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / common / headers.h / windialogutils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-29  |  5.9 KB  |  209 lines

  1. /*
  2.     File: WinDialogUtils.h
  3.  
  4.     Copyright 1996, Adobe Systems Incorporated.
  5.     All rights reserved.
  6.  
  7.     Header file for C source file for MS-Windows specific dialog code
  8. */
  9.  
  10. #ifndef __WinDialogUtils_H__
  11. #define __WinDialogUtils_H__
  12.  
  13. #include <limits.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <windows.h>
  17. #include <errno.h>
  18.  
  19. #include "PITypes.h"
  20. #include "PIAbout.h"
  21. #include "PIUtilities.h"
  22.  
  23. /*****************************************************************************/
  24. /* Define constants. */
  25.  
  26.  
  27. /* Define errors */
  28.  
  29. enum
  30. {
  31.     /* noErr = 0 */
  32.     errOutOfRange = 1,
  33.     errNotANumber
  34. };
  35.  
  36. /*****************************************************************************/
  37. /* The following routine displays a standard about box dialog. */
  38.  
  39. void ShowAbout(AboutRecordPtr aboutPtr, Handle hDllInstance, int32 resID);
  40.  
  41. /*****************************************************************************/
  42. /* The following routine displays a centered alert. */
  43.  
  44. short ShowAlert (short alertID);
  45.  
  46. /* Displays a cross-platform alert with a version number. */
  47.  
  48. short ShowVersionAlert (Handle hDllInstance,
  49.                         HWND hDlg,
  50.                         short alertID, 
  51.                         short stringID,
  52.                         Str255 versText1,
  53.                         Str255 versText2);
  54.  
  55. /* The following routine displays a centered caution alert from a string. */
  56.  
  57. short ShowAlertType (Handle hDllInstance,
  58.                      HWND hDlg,
  59.                      short alertID, 
  60.                      short stringID, 
  61.                      Str255 minText, 
  62.                      Str255 maxText,
  63.                      short alertType);
  64.  
  65. enum
  66. { // constants defined for alert routine
  67.     PIAlertCaution,
  68.     PIAlertStop
  69. };
  70.  
  71. #define ShowCaution(h, hDlg, alertID, stringID, min, max)    \
  72.     ShowAlertType(h, hDlg, alertID, stringID, min, max, PIAlertCaution)
  73.     
  74. #define ShowStop(h, hDlg, alertID, stringID, min, max)    \
  75.     ShowAlertType(h, hDlg, alertID, stringID, min, max, PIAlertStop)
  76.  
  77. /*****************************************************************************/
  78.  
  79. /* Fixpoint function used in Acquire. */
  80.  
  81. Fixed FixRatio(short numer, short denom);
  82.  
  83. /*******************************************************************************/
  84. /* Centers a dialog template 1/3 of the way down on the main screen */
  85.  
  86. void CenterDialog(HWND hDlg);
  87.  
  88. /************************************************************************/
  89. /* Utility function to return which item of a group of radio buttons is */
  90. /* checked.                                                                */
  91. short GetRadioGroupState (HWND hDlg, short nItem1, short nItemL);
  92.  
  93. /****************************************************************************/
  94. /* Selects a text item */
  95. void SelectTextItem(HWND hDlg, short item);
  96.  
  97. /****************************************************************************/
  98. /* Sets the default dialog item */
  99. void SetDialogDefaultItem(HWND hDlg, short item);
  100.  
  101. /*********************************************************************/
  102. /* Shows a dialog item */
  103. void ShowDialogItem(HWND hDlg, short item);
  104.  
  105. /*********************************************************************/
  106. /* Hides a dialog item */
  107. void HideDialogItem(HWND hDlg, short item);
  108.  
  109. /*********************************************************************/
  110. /* Hides or shows a dialog item */
  111. void ShowHideItem(HWND hDlg, short item, BOOL state);
  112.  
  113. /*********************************************************************/
  114. /* Enables a dialog item */
  115. void EnableControl(HWND hDlg, short item);
  116.  
  117. /*********************************************************************/
  118. /* Disables a dialog item */
  119. void DisableControl(HWND hDlg, short item);
  120.  
  121. /*********************************************************************/
  122. /* Enables or disables a dialog item */
  123. void EnableDisableControl(HWND hDlg, short item, BOOL state);
  124.  
  125. /*********************************************************************/
  126. /* Toggles and returns value of check box */
  127. BOOL ToggleCheckBoxState(HWND hDlg, short item);
  128.  
  129. /*****************************************************************************/
  130. /* Retrieves a pascal text string from a text field. */
  131. void FetchText (HWND hDlg, short item, Str255 s);
  132.  
  133. /********************************************************************/
  134. /* Stuffs a pascal string into a text field */
  135. void StuffText (HWND hDlg, short item, Str255 s);
  136.  
  137. /*********************************************************************/
  138. /* Retrieves a number from a dialog item. Returns true if successful. */
  139. /* Automatically pins value to min >= value >= max, setting dialog */
  140. /* item and beeping if out of bounds. */
  141.  
  142. short FetchNumber(HWND hDlg, 
  143.                  short item, 
  144.                  int32 min, 
  145.                  int32 max, 
  146.                  int32 *value);
  147.  
  148. /* Corresponding alert routine to pop error */
  149.  
  150. void AlertNumber(HWND hDlg, 
  151.                  short item, 
  152.                  int32 min, 
  153.                  int32 max, 
  154.                  int32 *value,
  155.                  Handle hDllInstance,
  156.                  short alertID,
  157.                  short numberErr);
  158.  
  159. void StuffDouble (HWND dp, short item, double value, short precision);
  160.  
  161. short FetchDouble (HWND dp,
  162.                     short item,
  163.                     double min,
  164.                     double max,
  165.                     double *value);
  166.  
  167.  
  168. void AlertDouble (HWND dp,
  169.                  short item,
  170.                  double min,
  171.                  double max,
  172.                  double *value,
  173.                  Handle hDllInstance,
  174.                  short alertID,
  175.                  short numberErr);
  176.  
  177. /*********************************************************************/
  178. /* Standardize terminology */
  179.  
  180. #define    ok            1
  181. #define cancel        2
  182.  
  183. #define SetRadioGroupState(dp, first, last, item)    \
  184.     CheckRadioButton(dp, first, last, item)
  185.  
  186. #define SetCheckBoxState(dp, item, state)    \
  187.     CheckDlgButton(dp, item, state)
  188.  
  189. #define GetCheckBoxState(dp, item)    \
  190.     IsDlgButtonChecked(dp, item)
  191.  
  192. #define StuffNumber(dp, item, value)    \
  193.     SetDlgItemInt(dp, item, value, TRUE)
  194.  
  195. #define GETWSTYLE(X)         GetWindowLong((HWND)X, GWL_STYLE)
  196. #define COMMANDWND(lParam)   (HWND)(UINT)lParam
  197. #define COMMANDID(X)         LOWORD(X)
  198.  
  199. #ifdef WIN32
  200. #define COMMANDCMD(X, Y)    HIWORD(X)
  201. #define huge
  202. #ifndef PDECL
  203. #define PDECL
  204. #endif
  205. #else
  206. #define COMMANDCMD(X, Y)    HIWORD(Y)
  207. #endif
  208.  
  209. #endif /* __WinDialogUtils_H__ */